package com.woniu05.comparabl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Test01 {
    public static void main(String[] args) {
        List<Person> people = new ArrayList<>();
        people.add(new Person("Alice", 25));
        people.add(new Person("Bob", 20));
        people.add(new Person("Charlie", 30));

        Collections.sort(people); // 使用 Person 的自然排序（按年龄）

        System.out.println(people);
// 输出: [Bob (20), Alice (25), Charlie (30)]
    }
}
